<?php
/**
 * Created by PhpStorm.
 * User: Inhere
 * Date: 14-4-8
 * Time: 上午11:23
 */

header("Content-Type: text/html; Charset = ANSI");

// set runtime env
define('APP_ENV'  , 'cli');

// $allowIp = ['127.0.0.1', 'fe80::1', '::1'];
if ( PHP_SAPI != 'cli' )
{
    header('HTTP/1.0 403 Forbidden');
    exit("<h1>403 Forbidden</h1>\n:( Sorry! Run this script is only allowed in the terminal environment!\n,You are not allowed to access this file.\n");
}

// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));

defined('APP_DEBUG')    or define('APP_DEBUG', false);
defined('APP_TRACE')    or define('APP_TRACE', false);
error_reporting(E_ALL);

require_once __DIR__ . '/core/define.php';

$loader = require __DIR__ . '/newLoader/autoload.php';

// service configurator
$configurator = new ulue\cli\Configurator( Ulue::loadServiceConfig(APP_ENV) );

/* ===============创建容器,注册基本服务=============== */
$configurator->getDi()->share('loader', $loader);
$container = $configurator->registerService();

return $container;

// // ===============创建应用容器===============
// $container = \Ioc::build();
// $container->share('loader', $loader)->alias('app.loader');

// // ==============运行项目===================
// $app = new \ulue\cli\Application( $container );

// $app->execute();


